#!/usr/bin/env python
# -*- coding: utf-8 -*-

#import h5py
#import mat4py
import scipy.io as sio
#import reconDAS
import numpy as np
import matplotlib.pyplot as plt

class TestClass(object):
    # 类变量
    val1 = 100
    def __init__(self):
        # 成员变量
        self.val2 = 200

    def fcn(self, val=400):
        val3 = 300
        self.val4 = val
        self.val5 = 500



if __name__ == '__main__':
    # import sys
    # import cgitb

    # com_list = QSerialPortInfo.availablePorts()
    # com = QSerialPort()

    #mat = h5py.File("D:/Project/Data/data.mat")
    # mat = mat4py.loadmat("D:/Project/Data/data.mat")
    # print(type(mat))
    # print(mat.keys())

    mat = sio.loadmat("E:/YCS_Temp/project/thesis_dataset/dataset/PA_dataset/cartilage_plate_0033_pa_rf.mat")
    print(type(mat))
    print(mat.keys())
    print(type(mat['rf_data']))
    print(mat['rf_data'].shape)
    print(mat['optical_absorption'])
    pa_sensor_data = mat['rf_data']

    # 选择要绘制的一行数据，例如第一行
    sensor_index = 63
    row_data = pa_sensor_data[:, sensor_index]

    # 绘制折线图
    plt.figure(figsize=(10, 6))
    plt.plot(row_data, label = f'Row {sensor_index + 1} Data')
    plt.title(f'PA RF Data - Row {sensor_index + 1}')
    plt.xlabel('Element Number')
    plt.ylabel('Amplitude')
    plt.legend()
    plt.grid(True)
    plt.show()

    mat = sio.loadmat("E:/YCS_Temp/project/thesis_dataset/dataset/US_dataset/cartilage_plate_0033_us_rf.mat")
    print(type(mat))
    print(mat.keys())
    print(type(mat['rf_data']))
    print(mat['rf_data'].shape)
    print(mat['acoustic_impedance'])
    pa_sensor_data = mat['rf_data']

    # 选择要绘制的一行数据，例如第一行
    sensor_index = 0
    row_data = pa_sensor_data[:, sensor_index]

    # 绘制折线图
    plt.figure(figsize=(10, 6))
    plt.plot(row_data, label = f'Row {sensor_index + 1} Data')
    plt.title(f'PA RF Data - Row {sensor_index + 1}')
    plt.xlabel('Element Number')
    plt.ylabel('Amplitude')
    plt.legend()
    plt.grid(True)
    plt.show()

    # mat = h5py.File("D:/Project/Data/PAUSdata.mat")
    # print(type(mat))
    # print(mat.keys())

    # reconDAS = reconDAS.initialize()
    # path = 'D:/Project/PA/reconDAS/Rawdata_FPGA1_Frame9.bin'
    # img = reconDAS.reconDAS(path)
    # print(type(img))
    # npimg = np.array(img)
    # print(type(npimg))
    # print(np.shape(npimg))
